package com.rain.lo.service.impl;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.rain.lo.dao.ProjectDao;
import com.rain.lo.entity.Project;
import com.rain.lo.service.ProjectService;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
import java.util.Map;

@Service("projectService")
public class ProjectServiceImpl implements ProjectService {
    @Resource
    private ProjectDao projectDao;
/*    @Override
    public Map<String,List<Project>> list() {
        List<Project> pList = projectDao.list(null,null);
        Map<String,List<Project>> pMap = Maps.newHashMap();
        pList.forEach(p->{
            if (p.getParent()==0){

            }
            List<Project> pList1 = pMap.get(p.getParent().toString());
            if (CollectionUtils.isEmpty(pList1)){
                pList1= Lists.newArrayList();
                pMap.put(p.getParent().toString(),pList1);
            }
            pList1.add(p);
        });
        return pMap;
    }*/

    @Override
    public List<Project> list(Integer parent) {
        return projectDao.list(parent);
    }

    @Override
    public List<Project> list() {
        return projectDao.list(null);
    }

    @Override
    public Long count() {
        return null;
    }
}
